package org.casper.outofmemory;

import javassist.CannotCompileException;
import javassist.ClassPool;

public class TestMetaSpace {
	
	static ClassPool classPool = ClassPool.getDefault();
	/**
	 * 说明：必须是jdk1.8
	 * 演示异常：java.lang.OutOfMemoryError:Metaspace
	 * 执行参数：-verbose:gc
	 * 解决方法：-XX:MaxMetaspaceSize=2g
	 */
	public static void main(String[] args) throws CannotCompileException, RuntimeException {
		
		for(int i=0;;i++){
			@SuppressWarnings({ "rawtypes", "unused" })
			Class c = classPool.makeClass("myclass"+i).toClass();
		}
	}
}
